package com.bsj.sipgateway.web.controller;

import com.bsj.power.common.config.global.JsonResult;
import com.bsj.power.common.def.dto.room.RoomDTO;
import com.bsj.power.common.def.dto.room.RoomSearchDTO;
import com.bsj.power.common.def.vo.video.room.RoomVO;
import com.bsj.sipgateway.web.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author LiJiaXin
 * @version 1.0.0
 * @description RoomController
 * @time 2024/9/3 11:21
 */
@RestController
@RequestMapping("/room")
//@SaCheckPermission("/video/room")
public class RoomController {

    @Autowired
    @Qualifier("roomServiceImpl")
    private RoomService roomService;

    /**
     * 添加房间
     *
     * @param roomDTO
     * @return com.bsj.power.common.config.global.JsonResult
     * @author ljx
     * @time 2024/9/3 12:01
     */
    @PostMapping("/add")
    public JsonResult add(@Validated @RequestBody RoomDTO roomDTO) {
        return roomService.addRoom(roomDTO);
    }

    /**
     * 删除房间
     *
     * @param roomId
     * @return com.bsj.power.common.config.global.JsonResult
     * @author ljx
     * @time 2024/9/3 12:01
     */
    @PostMapping("/delete/{roomId}")
    public JsonResult delete(@PathVariable("roomId") Long roomId) {
        return roomService.deleteRoom(roomId);
    }

    /**
     * 修改房间
     *
     * @param roomDTO
     * @return com.bsj.power.common.config.global.JsonResult
     * @author ljx
     * @time 2024/9/3 12:02
     */
    @PostMapping("/update")
    public JsonResult update(@Validated @RequestBody RoomDTO roomDTO) {
        return roomService.updateRoom(roomDTO);
    }

    /**
     * 获取单个房间信息
     *
     * @param roomId
     * @return com.bsj.power.common.config.global.JsonResult
     * @author ljx
     * @time 2024/9/3 12:02
     */
    @GetMapping("/getById/{roomId}")
    public JsonResult<RoomVO> getById(@PathVariable("roomId") Long roomId) {
        return JsonResult.success(roomService.getRoomById(roomId));
    }

    /**
     * 房间信息分页
     *
     * @param roomSearchDTO
     * @return com.bsj.power.common.config.global.JsonResult<java.util.List < com.bsj.power.common.def.vo.video.room.RoomVO>>
     * @author ljx
     * @time 2024/9/3 12:04
     */
    @GetMapping("/page")
    public JsonResult<List<RoomVO>> page(@Validated RoomSearchDTO roomSearchDTO) {
        return roomService.pageRoom(roomSearchDTO);
    }

    /**
     * 根据房间号查询视频设备信息
     *
     * @param roomNo
     * @return com.bsj.power.common.config.global.JsonResult<com.bsj.power.common.def.vo.video.room.RoomVO>
     * @author ljx
     * @time 2024/9/8 20:26
     */
    @GetMapping("/getVideoDevicesByRoomNo")
    public JsonResult<RoomVO> getVideoDevicesByRoomNo(String roomNo) {
        return JsonResult.success(roomService.getVideoDevicesByRoomNo(roomNo));
    }

}
